package cn.hqc.basic.service.impl;


import cn.hqc.basic.service.EchartService;
import cn.hqc.org.mapper.ShopMapper;
import cn.hqc.org.vo.EchartVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class EchartServiceImpl implements EchartService {

    @Autowired
    private ShopMapper shopMapper;

    @Override
    public Map<String, Object> echart() {
        // 需要查询 当前店铺 的 状态 以及店铺的状态下的个数
        List<EchartVo> vo = shopMapper.echart();
        List<Integer> stateList = vo.stream().map(EchartVo::getState).collect(Collectors.toList());
        List<Integer> countList = vo.stream().map(EchartVo::getStateCount).collect(Collectors.toList());
        Map<String,Object> result = new HashMap<>();
        // 状态
        result.put("x",stateList);
        // 个数
        result.put("y",countList);

        return result;
    }
}
